package com.yh.ldzl.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.yh.ldzl.domain.QcInspectionMini;
import com.yh.ldzl.service.QcInspectionMiniService;
import com.yh.ldzl.service.LotTraceabilityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;


/**
 * 检验任务Controller 待检任务和批次追溯任务
 *
 * @author yanghuai
 * @date 2025-07-10
 */
@RequestMapping("/qc/inspectionTask")
@RestController
public class InspectionTaskController extends BaseController {

    @Autowired
    private QcInspectionMiniService qcInspectionMiniService;
    
    @Autowired
    private LotTraceabilityService lotTraceabilityService;
    
    /**
     * 查询待检任务列表
     */
    @GetMapping("/QcInspectionMiniList")
    public TableDataInfo list(QcInspectionMini qcInspectionMini) {
        startPage();
        List<QcInspectionMini> list = qcInspectionMiniService.QcInspectionMiniList(qcInspectionMini);
        return getDataTable(list);
    }

    /**
     * 查询批次追溯列表
     */
    @GetMapping("/lotTraceabilityList")
    public TableDataInfo lotTraceabilityList(Map<String, Object> params) {
        startPage();
        List<Map<String, Object>> list = lotTraceabilityService.selectLotTraceabilityList(params);
        return getDataTable(list);
    }

    /**
     * 根据批次号查询OQC信息
     */
    @GetMapping("/lotTraceabilityOqc/{sales_id}")
    public List<Map<String, Object>> lotTraceabilityOqc(@PathVariable("sales_id") Long sales_id) {
        return lotTraceabilityService.selectLotTraceabilityBatchCodeOqc(sales_id);
    }

    /**
     * 根据批次号查询产品销售信息
     */
    @GetMapping("/lotTraceabilitySales/{sales_id}")
    public List<Map<String, Object>> lotTraceabilitySales(@PathVariable("sales_id") Long sales_id) {
        return lotTraceabilityService.selectLotTraceabilityBatchCodeCkProductSales(sales_id);
    }

}
